<?php

use app\modules\admin\widgets\gird\GridWidget;
use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $searchModel app\modules\admin\models\search\MenuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '菜单';
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="row">
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <div class="col-sm-12">
        <?= GridWidget::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'title' => $this->title,
            'toolButtons' => [
                    Html::a('<i class="fa fa-file-o"></i> 新建菜单', ['menu/create'], [
                        'class' => 'btn btn-success',
                    ]),
            ],
            'columns' => [
                'name',
                [
                    'attribute' => 'parentMenu.name',
                    'filter' => Html::activeTextInput($searchModel, 'parent_name',[
                        'class' => 'form-control',
                    ]),
                    'format' => 'raw',
                    'value' => function($m) {
                        $infoIcon = '<span class="fa fa-info-circle"></span> ';
                        if ($m->parent !== null) {
                            return $m->parentMenu->name;
                        } else {
                            return $infoIcon . '顶层菜单';
                        }
                    },
                    'label' => '上级菜单',
                ],
                'route',
                'order',

                ['class' => 'yii\grid\ActionColumn'],
            ],
        ]) ?>
    </div>
</div>
